﻿using System;
using System.IO;

namespace ConsoleApp1
{
    class Program
    {

        static void Main(string[] args)
        {
            
            DirectoryInfo directoryInfo = new DirectoryInfo("D:\\mySolo");
            directoryInfo.Create();
            FileInfo fileInfo = new FileInfo("D:\\mySolo\\test.txt");
            if (!fileInfo.Exists)
            {
                fileInfo.Create().Close();
            }
            string path = @"D:\\mySolo\\test.txt";
            StreamWriter stream = new StreamWriter(path);
            stream.WriteLine("拥抱着你的滋味");
            stream.WriteLine("红色高跟鞋");
            stream.WriteLine("未来式情歌");
            stream.Flush();
            stream.Close();


            string path1 = @"D:\Mango";
            try
            {
                if (!Directory.Exists(path1))
                {
                    Directory.CreateDirectory(path1);
                }
                using (StreamWriter sw = new StreamWriter("D:\\Mango\\text.txt", true))
                {
                    sw .WriteLine("拥抱着你的滋味");
                    sw .WriteLine("红色高跟鞋");
                    sw .WriteLine("未来式情歌");
                }
            }
            finally { }





            /*
             static void Save(string path, string str)
            {
                string s = path.Substring(0, path.LastIndexOf('\\'));
                Directory.CreateDirectory(s);//如果文件夹不存在就创建它
                FileStream fs = new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
                byte[] data = System.Text.Encoding.Default.GetBytes(str);
                //开始写入
                fs.Write(data, 0, data.Length);
                //清空缓冲区、关闭流
                fs.Flush();
                fs.Close();
            }
            



            string txtPath = ConfigurationManager.AppSettings["TxtFile"];//获取配置文件的文件存放地址
            string filePath = txtPath + "/" + DateTime.Now.ToString("yyyyMMdd");
            if (!Directory.Exists(filePath))
            {
                Directory.CreateDirectory(filePath);
            }
            string[] files = Directory.GetFiles(filePath);
            string fileAllName = filePath + "/" + DateTime.Now.Date.ToString("yyyyMMdd") + ".txt";
            File.WriteAllText(fileAllName, contents);

            */
        }
    }
    
}
